﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>部门管理</title>
    <link href="~/Content/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" />
    @*CSS样式(包含默认皮肤样式)*@

    <link href="~/Content/jquery.bsgrid-1.37/builds/merged/bsgrid.all.min.css" rel="stylesheet" />
    <link href="~/Content/Tree/jsTree/style.min.css" rel="stylesheet" />
    @*自定义样式*@
    <style type="text/css">
        .container {
            width: 100%;
            padding: 0;
        }

        .panel-heading {
            font-size: 16px;
            text-align: center;
        }

        .panel-body {
            padding-top: 0;
        }

            .panel-body label {
                font-weight: normal;
                font-size: 16px;
            }

        .setPadding {
            border: 1px solid #eee;
            padding: 5px 0 5px 10px;
        }

            .setPadding button {
                padding: 4px 6px;
                font-size: 12px;
            }

        .form-horizontal label {
            font-size: 12px;
        }

        .form-horizontal select, .form-horizontal input {
            height: 26px;
            padding: 0;
        }

        .reset {
            padding: 0;
        }

        .examineeInfor {
            border: 1px solid #eee;
            padding: 0;
        }

        .h5 {
            margin: 0;
            background: #eef;
            padding: 6px 10px;
        }

        .examineeInfor th, .examineeInfor td {
            font-weight: normal;
            text-align: center;
        }

        #examineeInfor th {
            padding: 4px 8px;
        }

        .modal-header {
            padding: 6px 5px;
            border-bottom: none;
            background: #337ab7;
            text-align: center;
            color: #fff;
        }

        .modal-content {
            padding: 6px;
        }

        .modal-body {
            border: 1px solid #ddd;
            padding: 0 25px;
        }

        .modal-content label {
            font-weight: normal;
            font-size: 12px;
        }

        .img-box {
            border: 1px solid #eee;
            padding: 10px;
        }

        .modal-dialog {
            width: 400px;
        }

        .modal .form-group {
            margin-bottom: 0;
            margin-top: 2px;
        }

        .form-group input {
            height: 26px;
        }

        .setSex {
            position: relative;
            top: -10px;
            left: 2px;
        }

        .text-center {
            color: red;
        }
    </style>
</head>
<body>
    @*页面*@
    <div class="container">
        <div class="panel">
            <div class="panel-heading">部门管理</div>
            <div class="panel-body">
                @*搜索栏按钮栏*@
                <div class="row">
                    <div class="col-lg-2 col-md-2 col-sm-2">
                        <div id="B"></div>
                    </div>
                    <div class="row setPadding" style="margin-left: -13px">
                        @*按钮*@
                        <div class="col-lg-10 col-md-5 col-sm-5" style="float:right">
                            <button class="btn btn-group" type="button" id="close">关闭</button>
                            <button class="btn btn-group" type="button" id="refresh">刷新</button>
                            <button class="btn btn-group" type="button" id="add">新增</button>
                            <button class="btn btn-group" type="button" id="redact">编辑</button>
                            <button class="btn btn-group" type="button" id="delete">删除</button>
                            <button class="btn btn-group" type="button" id="demand">查询</button>
                            <button class="btn btn-group" type="button" id="Stamp">打印</button>
                            <button class="btn btn-group" type="button" id="DaoChu">导出</button>
                        </div>

                        @*表格数据绑定*@
                        <div class="col-lg-10 col-md-5 col-sm-5" style="float:right">
                            <table id="Tiss" style="width:100%">
                                <tr>
                                    <th w_check="true" w_index="DepartmentID"></th>
                                    <th w_num="total_line">NO.</th>
                                    <th w_index="DepartmentName">部门名称</th>
                                    <th w_index="DepartmentMobile">联系电话</th>
                                    <th w_index="InteriorPhone">内部电话</th>
                                    <th w_index="DepartmentTop">部门领导</th>
                                    <th w_index="DepartmentDuty">部门职责</th>
                                    <th w_index="DepartmentDescribe">部门描述</th>
                                    <th w_index="">部门编号</th>
                                    <th w_index="ChineseName">所属组织</th>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            @*新增考生模态窗体*@
            <div class="modal  bs-example-modal-sm" id="modInsertExaminee">
                <div class="modal-dialog">
                    <div class="modal-content">
                        @*模态框头部*@
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">
                                <span aria-hidden="true">&times;</span>
                                <span class="sr-only">Close</span>
                            </button>
                            <h5 class="modal-title">蓝色的帅气</h5>
                        </div>
                        @*新增模态框内容*@
                        <div class="modal-body">
                            <form class="form-horizontal" role="form" id="formInsertExaminee" action="InsertStudent" method="post">
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">部门名称:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="DepartmentName" name="DepartmentName" autocomplete="off" />
                                        @*<lable id="StudentIDNumlength" style="font:12px;color:#0094ff;">00位</lable>*@
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">联系电话:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="DepartmentMobile" name="DepartmentMobile" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">内部电话：</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="InteriorPhone" name="InteriorPhone" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">部门领导:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="DepartmentTop" name="DepartmentTop" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">部门职责:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="DepartmentDuty" name="DepartmentDuty" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">部门描述:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="DepartmentDescribe" name="DepartmentDescribe" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">部门编号:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">
                                        <input type="text" class="form-control" id="DepartmentID" name="DepartmentID" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-3 col-md-3 col-sm-3 text-right">
                                        <label class="control-label">所属组织:</label>
                                    </div>
                                    <div class="col-lg-8 col-md-8 col-sm-8 reset">

                                        <select type="text" class="form-control" id="Message" name="MessageID"></select>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group" style="padding:10px;">
                                        <div class="col-lg-8 col-md-8 col-sm-8 pull-right">
                                            <button class="btn btn-primary" type="reset" id="l">查询</button>
                                            <button class="btn btn-primary" type="reset" id="ll">新增</button>
                                            <button class="btn btn-primary" type="reset" id="lll">重置</button>
                                            <button class="btn btn-primary" type="reset" id="llll">修改</button>
                                            <button class="btn btn-primary" type="button" id="lllll">保存</button>
                                            <button class="btn btn-danger" data-dismiss="modal">关闭</button>
                                        </div>
                                    </div>
                                </div>


                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    @*外部js引用*@
    <script src="~/Content/Tree/jquery.min.js"></script>
    <script src="~/Content/bootstrap-3.3.7-dist/js/jquery-2.0.3.min.js"></script>
    <script src="~/Content/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>@*jquery.bsgrid*@
    <script src="~/Content/jquery.bsgrid-1.37/builds/js/lang/grid.zh-CN.min.js"></script>
    <script src="~/Content/jquery.bsgrid-1.37/builds/merged/bsgrid.all.min.js"></script>@*查询表格*@
    <script src="~/Content/layer/layer.js"></script>@*对话框*@

    <script src="~/Content/js/customfunction.js"></script>@*下拉框数据绑定、表单数据回填*@
    <script src="~/Content/js/combobox.js"></script>   @*点击选中行*@
    <script src="~/Content/js/jquery.form.js"></script>@*提交表单*@
    <script src="~/Content/Tree/jstree.min.js"></script>
    <script src="~/Content/Tree/Tree.js"></script>
    <script>
        var cccc;
        Tree("#B", "/PPAP/BranchManagement/tree");

        $(function () {
            //初始化表格数据
            cccc = $.fn.bsgrid.init("Tiss", {
                url: "SelectDepartment",
                autoLoad: true,
                pageSizeSelect: true,//分页大小选择下拉框
                pageSize: 7,//初始化每一页数据条数
                stripeRows: true,//隔行换色
                rowHoverColor: true,//鼠标滑过变色
                pagingLittleToolbar: true,//精简的图标按钮分页工具条
                displayBlankRows: false,//不显示空白行
                event: {
                    //当前行事件
                    customRowEvents: {
                        click: function (record, rowIndex, trObj, options) {
                            //调用行点击事件
                            Check("#Tiss tr", rowIndex + 1);
                            cccccc(record);
                        }
                    }
                }
            });
            appendOption("Message", "/Main/Message")
        });
        function Tree1(DepartmentID) {
            tttt.search({ DepartmentID: DepartmentID })
        }

        $("#close").click(function () {//关闭
            window.history.go(-1);
        });
        $("#refresh").click(function () {
            location.reload();//刷新
        });

        /*********************** 查询条件****************************/
        $("#demand").click(function () {//查询弹出模态框

            $("#modInsertExaminee").modal("show");

            $("#l").css("display", "block");
            //  隐藏按钮
            $("#ll").css("display", "none");//新增
            $("#lll").css("display", "none");//重置
            $("#llll").css("display", "none");//修改
            $("#lllll").css("display", "none");//保存
            $("#l").click(function () {
                $("#modInsertExaminee").modal("hide");
            });
            //        //多条件查询
            $("#l").click(function () {//获取文本框信息
                var DepartmentName = $("#DepartmentName").val();//部门名称
                var DepartmentMobile = $("#DepartmentMobile").val();//联系电话
                var InteriorPhone = $("#InteriorPhone").val();//内部电话
                var DepartmentTop = $("#DepartmentTop").val();//部门领导
                var DepartmentDuty = $("#DepartmentDuty").val();//部门职责
                var DepartmentDescribe = $("#DepartmentDescribe").val();//部门描述
                var Message = $("#Message").val();//所属组织
                if (DepartmentName == undefined || DepartmentName == null) {
                    DepartmentName = "";
                }
                if (DepartmentMobile == undefined || DepartmentMobile == null) {
                    DepartmentMobile = "";
                }
                if (InteriorPhone == undefined || InteriorPhone == null) {
                    InteriorPhone = "";
                }
                if (DepartmentTop == undefined || DepartmentTop == null) {
                    DepartmentTop = "";
                }
                if (DepartmentDuty == undefined || DepartmentDuty == null) {
                    DepartmentDuty = "";
                }
                if (DepartmentDescribe == undefined || DepartmentDescribe == null) {
                    DepartmentDescribe = "";
                }
                if (Message == "" || Message == 0) {
                    Message = 0;
                }
                cccc.search({ DepartmentName: DepartmentName, DepartmentMobile: DepartmentMobile, InteriorPhone: InteriorPhone, DepartmentTop: DepartmentTop, DepartmentDuty: DepartmentDuty, DepartmentDescribe: DepartmentDescribe, MessageID: Message });

            });
        });

        /**************************新增**********************************/
        $("#add").click(function () {  //新增弹出框
            $("#modInsertExaminee").modal("show");
            $("#lllll").css("display", "block");
            //隐藏
            $("#l").css("display", "none");//查询
            $("#ll").css("display", "none");//新增
            $("#lll").css("display", "none");//重置
            $("#llll").css("display", "none");//修改
            $("#lllll").click(function () {
                $("#modInsertExaminee").modal("hide");
            });
            $("#lllll").click(function () {
                //获取新增数据
                var DepartmentName = $("#DepartmentName").val();
                var DepartmentMobile = $("#DepartmentMobile").val();
                var InteriorPhone = $("#InteriorPhone").val();
                var DepartmentTop = $("#DepartmentTop").val();
                var DepartmentDuty = $("#DepartmentDuty").val();
                var DepartmentDescribe = $("#DepartmentDescribe").val();
                var MessageID = $("#Message").val();

                //   请求数据
                $.getJSON("InsertDepartment?DepartmentName=" + DepartmentName + "&DepartmentMobile=" + DepartmentMobile + "&InteriorPhone=" + InteriorPhone + "&DepartmentTop=" + DepartmentTop + "&DepartmentDuty=" + DepartmentDuty + "&DepartmentDescribe=" + DepartmentDescribe + "&MessageID=" + MessageID,
                    function (data) {
                        if (data == "success") {
                            //刷新页面
                            location.reload();
                        }
                    });
            });
        });

        //**********************************

        //***********************修改***********************************
        $("#redact").click(function () {
            //隐藏按钮
            $("#l").css("display", "none");//查询
            $("#ll").css("display", "none");//新增
            $("#lllll").css("display", "none");//保存
            //显示按钮
            $("#lll").css("display", "block");//重置
            $("#llll").css("display", "block");//修改
            var Check = $("#Tiss input:checked");
            if (Check.length == 0) {
                layer.msg("请选择一条信息", { icon: 0, })
            }
            if (Check.length > 1) {
                layer.msg("只能选择一条信息", { icon: 0 });
            }
            if (Check.length == 1) {
                $("#modInsertExaminee").modal("show");
            }
        });
        //数据回填
        function cccccc(record) {
            $("#DepartmentName").val(record.DepartmentName).val().trim();
            $("#DepartmentMobile").val(record.DepartmentMobile).val().trim();
            $("#InteriorPhone").val(record.InteriorPhone).val().trim();
            $("#DepartmentTop").val(record.DepartmentTop).val().trim();
            $("#DepartmentDuty").val(record.DepartmentDuty).val().trim();
            $("#DepartmentDescribe").val(record.DepartmentDescribe).val().trim();
            $("#DepartmentID").val(record.DepartmentID).val().trim();
            $("#Message").val(record.MessageID).val().trim();
        }
        $("#llll").click(function () {
            //修改保存
            var Check = $("#Tiss input:checked");
            var DepartmentName = $("#DepartmentName").val().trim(); //部门名称
            var DepartmentMobile = $("#DepartmentMobile").val().trim();//  联系电话
            var InteriorPhone = $("#InteriorPhone").val().trim();//内部电话
            var DepartmentTop = $("#DepartmentTop").val().trim();//部门领导
            var DepartmentDuty = $("#DepartmentDuty").val().trim();//部门职责
            var DepartmentDescribe = $("#DepartmentDescribe").val().trim();//部门描述
            var DepartmentID = $("#DepartmentID").val().trim();//部门编号
            var MessageID = $("#Message").val().trim();    //下来狂
            //请求数据
            $.post("UpdateDepartment?DepartmentName=" + DepartmentName + "&DepartmentMobile=" + DepartmentMobile + "&InteriorPhone=" + InteriorPhone + "&DepartmentTop=" + DepartmentTop + "&DepartmentDuty=" + DepartmentDuty + "&DepartmentDescribe=" + DepartmentDescribe + "&MessageID=" + MessageID + "&DepartmentID=" + DepartmentID,//"&MessageID=" + Check[0].value,
                function (data) {
                    if (data == "success") {
                        //刷新页面
                        location.reload();
                    };
                });
        });
        //删除
        $("#delete").click(function () {
            //获取选中行
            var check = $("#Tiss  input:checked");
            //声明一个变量记录删除数据的条数
            //var ReturnLength = 0;
            if (check.length > 0) {
                layer.confirm("确定要删除吗？", {
                    icon: 3,
                    btn: ['确定', '取消'],
                    offset: "50px",
                }, function (layerIndex) {
                    //关闭提示框
                    layer.close(layerIndex);
                    for (var i = 0; i < check.length; i++) {
                        var DepartmentID = check[i].value;
                        $.ajax({
                            url: "DelectDepartment?DepartmentID=" + DepartmentID,
                            type: "get",//数据传输通道类型
                            async: false,
                            dataType: "json",
                            success: function (data) {
                                if (data) {
                                    location.reload();
                                } else {
                                    layer.msg(data, { icon: 0, title: "提示" });
                                }
                            }
                        });
                    }
                })
            }
            else {
                //引用第三方对话框。
                layer.alert("请选择要删除的信息", { icon: 0, title: '提示' });
            }
        });

        ///导出
        $("#DaoChu").click(function () {
            var DepartmentName = $("#DepartmentName").val().trim(); //部门名称
            var DepartmentMobile = $("#DepartmentMobile").val().trim();        //  联系电话
            var InteriorPhone = $("#InteriorPhone").val().trim();             //内部电话
            var DepartmentTop = $("#DepartmentTop").val().trim();            //部门领导
            var DepartmentDuty = $("#DepartmentDuty").val().trim();         //部门职责
            var DepartmentDescribe = $("#DepartmentDescribe").val().trim();//部门描述
            var DepartmentID = $("#DepartmentID").val().trim();           //部门编号
            var MessageID = $("#Message").val().trim();                  //下来狂

            if (DepartmentName == undefined || DepartmentName == null) {
                DepartmentName = "";
            }
            if (DepartmentMobile == undefined || DepartmentMobile == null) {
                DepartmentMobile = "";
            }
            if (InteriorPhone == undefined || InteriorPhone == null) {
                InteriorPhone = "";
            }
            if (DepartmentTop == undefined || DepartmentTop == null) {
                DepartmentTop = "";
            }
            if (DepartmentDuty == undefined || DepartmentDuty == null) {
                DepartmentDuty = "";
            }
            if (DepartmentDescribe == undefined || DepartmentDescribe == null) {
                DepartmentDescribe = "";
            }
            var str = "DepartmentName=" + DepartmentName + "&DepartmentMobile=" + DepartmentMobile + "&InteriorPhone=" + InteriorPhone + "&DepartmentTop=" + DepartmentTop + "&DepartmentDuty=" + DepartmentDuty + "&DepartmentDescribe=" + DepartmentDescribe
            if (cccc.getTotalPages() > 0) {
                layer.confirm("确定要导出当前数据吗？", {
                    icon: 3,
                    btn: ["确定", "取消"],
                }, function (layerIndex) {
                    layer.close(layerIndex)
                    window.open("DeriveDepartment?" + str);

                });
            } else {
                layer.msg("请先查询出考生，预览是否是需要导出的考生", { icon: 0, title: '提示' });
            }
        });

        //打印
        $("#Stamp").click(function () {
            var check = $("#Tiss input:checked");
            var DepartmentName = $("#DepartmentName").val().trim();             //部门名称
            var DepartmentMobile = $("#DepartmentMobile").val().trim();        //  联系电话
            var InteriorPhone = $("#InteriorPhone").val().trim();             //内部电话
            var DepartmentTop = $("#DepartmentTop").val().trim();            //部门领导
            var DepartmentDuty = $("#DepartmentDuty").val().trim();         //部门职责
            var DepartmentDescribe = $("#DepartmentDescribe").val().trim();//部门描述
            var DepartmentID = $("#DepartmentID").val().trim();           //部门编号
            var MessageID = $("#Message").val().trim();                  //下来狂
            DepartmentID
            if (DepartmentName == undefined || DepartmentName == null) {
                DepartmentName = "";
            }
            if (DepartmentMobile == undefined || DepartmentMobile == null) {
                DepartmentMobile = "";
            }
            if (InteriorPhone == undefined || InteriorPhone == null) {
                InteriorPhone = "";
            }
            if (DepartmentTop == undefined || DepartmentTop == null) {
                DepartmentTop = "";
            }
            if (DepartmentDuty == undefined || DepartmentDuty == null) {
                DepartmentDuty = "";
            }
            if (DepartmentDescribe == undefined || DepartmentDescribe == null) {
                DepartmentDescribe = "";
            }
            var str = "DepartmentName=" + DepartmentName + "&DepartmentMobile=" + DepartmentMobile + "&InteriorPhone=" + InteriorPhone + "&DepartmentTop=" + DepartmentTop + "&DepartmentDuty=" + DepartmentDuty + "&DepartmentDescribe=" + DepartmentDescribe
            if (cccc.getTotalPages() > 0) {
                layer.confirm("确定要打印当前数据吗？", {
                    icon: 3,
                    btn: ["确定", "取消"],
                }, function (layerIndex) {
                    layer.close(layerIndex)
                    window.open("StampDepartment?" + str);

                });
            } else {
                layer.msg("请先查询出考生，预览是否是需要打印的考生", { icon: 0, title: '提示' });
            }
        });

    </script>
</body>
</html>
